import {getToken} from "@/utils";
import {Navigate} from "react-router-dom";
import {message} from "antd";
// 鉴权路由
// children: 路由组件
// 如果token存在，则渲染children，否则跳转到登录页

export function AuthRoute({children}) {
    const token = getToken()
    if (token) {
        return children
    } else {
        message.error("请先登录")
        return <Navigate to="/login"/>
    }
}